using System;
using System.Collections.Generic;
using System.Text;
using Utility;
using Entites;
using DAL;

namespace BUS
{
   public class DoanhNghiepBUS
    {
          public static void Insert(DoanhNghiep dn)
        {
            DoanhNghiepDAL dnDAL = new DoanhNghiepDAL();
            dnDAL.Insert(dn);
        }
        public static void Update(DoanhNghiep dn)
        {
            DoanhNghiepDAL dnDAL = new DoanhNghiepDAL();
            dnDAL.Update(dn);
        }
        public static void Delete(int iD)
        {
            DoanhNghiepDAL dnDAL = new DoanhNghiepDAL();
            dnDAL.Delete(iD);
        }
        public static tbDoanhNghiepCollection Get(string where,
            int pageindex,
            int pagesize,
            string orderby,
            string orderdirection,
            out int total)
        {
            DoanhNghiepDAL dnDAL = new DoanhNghiepDAL();
            return dnDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbDoanhNghiepCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            DoanhNghiepDAL dnDAL = new DoanhNghiepDAL();
            return dnDAL.Get(cri.Criter, 0, 0, tbDoanhNghiepColumns.MaDN.ToString(), OrderDirection.ASC.ToString(), out total);
        }
       public static DoanhNghiep GetByID(int iD)
       {
           int total = 0;
           Criteria cri = new Criteria();
           cri.add(Condition.AND, tbDoanhNghiepColumns.MaDN.ToString(), Condition.EQUAL, iD);
           DoanhNghiepDAL dnDAL = new DoanhNghiepDAL();
           tbDoanhNghiepCollection doanhnghiepcollection = dnDAL.Get(cri.Criter,
                 0, 0, tbDoanhNghiepColumns.MaDN.ToString(), OrderDirection.ASC.ToString(), out total);
           if (doanhnghiepcollection.Count > 0)
               return doanhnghiepcollection[0];
           return null;
       }
      
        public static tbDoanhNghiepCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            DoanhNghiepDAL dnDAL = new DoanhNghiepDAL();
            return dnDAL.Get(cri.Criter, 1, number,
             tbDoanhNghiepColumns.MaDN.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbDoanhNghiepCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            DoanhNghiepDAL dnDAL = new DoanhNghiepDAL();
            return dnDAL.Get(cri.Criter, 1, number,
               tbDoanhNghiepColumns.MaDN.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
    
}
